<?php
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
session_start(); 
} 
include '../../operations/connection.php';	
$idcomment = $_REQUEST['idcomment'];
$idtestproject = $_REQUEST['idtestpro'];
$idemploy = $_REQUEST['idemp'];

	$newlang = $_REQUEST['newlang'];
		
		if ($_REQUEST['newlang'] == "EN") {
			include "../../value/value_en.php";
		} else if($_REQUEST['newlang'] == "VN") {
			include "../../value/value_vn.php";
		}
		else {
			include "../../value/value_kr.php";
		}
		
$sqldeletecomment = "DELETE FROM pr_comment WHERE pr_comment.IDComment = '$idcomment'";
mysql_query($sqldeletecomment);

$sqlreupdate ="update pr_testproject tp set 
tp.Comment_Last = (select c.Comment from pr_comment c, employee e where c.IDEmployee = e.IDEmployee and c.IDTestProject = tp.IDTest order by c.DateComment DESC limit 1)
, tp.NameEmployee_Last = (select e.FullName from pr_comment c, employee e where c.IDEmployee = e.IDEmployee and c.IDTestProject = tp.IDTest order by c.DateComment DESC limit 1) 
						where tp.IDTest = '$idtestproject'";
mysql_query($sqlreupdate);

$querycomment = mysql_query("select c.IDComment,c.IDTestProject,c.IDEmployee,c.Comment,c.DateComment,
								 e.IDEmployee,e.FullName,c.IDTestProject from pr_comment c, employee e 
									 where c.IDEmployee = e.IDEmployee and c.IDTestProject = '$idtestproject' ORDER BY  c.DateComment ASC")

?>

	                        <?php 
	                        if(count($querycomment)>0){
	                        	?>
	               <table style="width: 100%;">
	                        <?php  
		                        $vitri=0;
		                        while ($rowcoment = mysql_fetch_array($querycomment)){
		                        	$vitri++;
		                        		$idcomment = $rowcoment['IDComment'];
		                        		$idemployeecomment = $rowcoment['IDEmployee'];
										$stringcolor = $rowcoment['Comment'];
										if (strpos($stringcolor,"-%$#@!-#")) {
											$stringcolor =  substr($stringcolor,0,strpos($stringcolor,"-%$#@!-#"));
										}
										$stringcolor = strip_tags($stringcolor);
										?>
									
							<tr id="mo" style="background: <?php if($vitri%2==0) 
															echo '#f2f9ff'; 
													else echo '#ffffff';?>; font-size: 13px;">
								<td class="rf-dt-c" style="padding: 0; vertical-align: middle; width: auto;">
	                        
		                        	<span style=" color:#b023ab; font-size: 13px;">
		                        	<font color="#424242"><?php echo  " + ".$stringcolor ?></font>
									</span>
	                            	<i style="color:#424242; display:block; text-align:right; padding-top:5px;padding-right:15px; font-size: 13px;"><?php echo $rowcoment['FullName']." (".$rowcoment['DateComment'].")"?></i>
	                           </td>
	                           <td class="rf-dt-c" style="width: 25px; vertical-align: middle; text-align: center;min-width: 80px">
		                           <span onmouseover="this.style.cursor='pointer'" onmouseout="this.style.cursor='default'" style="color:#236DA4" 
		                           	onclick="if(confirm('<?php echo $l_confirm_deleteproject?>')){ delete_comment('<?=$idcomment?>','<?=$idtestproject?>','<?=$id_employee?>',this);return true}else{return false}">[ <?php echo $l_delete?> ]</span>
							   </td>
						</tr>
	                   <?php }?>
	               </table>
	               <?php }?>
	               <?mysql_close($connection);?>
	                      
                   